/*
 * ﻿Copyright (C) 2012-2013 NewMain Softech
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package com.newmainsoftech.ant.taskdefs;

import java.util.List;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Environment.Variable;

import com.newmainsoftech.ant.types.ArgumentExtContract;
import com.newmainsoftech.ant.types.CommandlineJavaExt;
import com.newmainsoftech.ant.types.SysPropExt;

/**
 * Wrapper of Ant's {@link Java} class to allow multi-line arguments for application and JVM. <br />
 * This overrides {@link Java#getCommandLine()} method to return {@link CommandlineJavaExt} object, 
 * in order to accept multi-line arguments.
 * <ul>
 * <li><h3>Usage example</h3>
 * <b>Use <code>javaext</code> tag</b> in Ant's <code>target</code> tag (what can be defined in 
 * <code>configuration</code> tag of manve-antrun-plugin's <code>execution</code> tag as well 
 * as in an Ant file).
 * <ul>
 * <li><b>To use multi-line arguments</b>
 * <ul>
 * <li><b>For JVM arguments, use <code>jvmargext</code> tag</b>
 * <blockquote>
 * <code>
 * &lt;<b>javaext</b> classname=&quot;com.newmainsoftech.ant.taskdefs.DummyAppForTestingJavaTaskExt&quot;&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>jvmargext</b>&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Xmx768m -Xss4M<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-javaagent:${agent_path}=nbjdk=JDK6u24;profile=java;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Xbootclasspath:${some_path}<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;/jvmargext&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * &lt;/javaext&gt;<br />
 * </code><br />
 * This <code>jvmargext</code> tag is equivalent of:<br />
 * <code>
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg value=&quot;-Xmx768m&quot; /&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg value=&quot;-Xss4M&quot; /&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg value=&quot;-javaagent:${agent_path}=nbjdk=JDK6u24;profile=java;&quot; /&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg value=&quot;-Xbootclasspath:${some_path}&quot; /&gt;<br />
 * </code> 
 * </blockquote>
 * </li>
 * <li><b>For arguments to target application, use <code>argext</code> tag</b>
 * <blockquote>
 * <code>
 * &lt;<b>javaext</b> classname=&quot;com.newmainsoftech.ant.taskdefs.DummyAppForTestingJavaTaskExt&quot;&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>argext</b>&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Dmulti-line-arg1=argext1 -Dmulti-line-arg2=argext2<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-Dmulti-line-arg3=${arg3_value}<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;some other argument&quot;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;/argext&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * &lt;/javaext&gt;<br />
 * </code><br />
 * This <code>argext</code> tag is equivalent of:<br />
 * <code>
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;arg value=&quot;-Dmulti-line-arg1=argext1&quot; &gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;arg value=&quot;-Dmulti-line-arg2=argext2&quot; &gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;arg value=&quot;-Dmulti-line-arg3=${arg3_value}&quot; &gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;arg value=&quot;some other argument&quot; &gt;<br />
 * </code>
 * </blockquote>
 * </li>
 * <li><b>For system properties, use <code>syspropext</code> tag</b>
 * <blockquote>
 * <code>
 * &lt;<b>javaext</b>&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>syspropext</b>&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gwt.args=-standardsMode -war ${war_dir} -logLevel WARN<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java.awt.headless=true<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gwt.devjar=${com.google.gwt:gwt-dev:jar}<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;java.util.logging.config.file=test/com/inetools/gwetons/client/devModeTest.logging.properties<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;/syspropext&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * &lt;/javaext&gt;<br />
 * </code><br />
 * This <code>syspropext</code> tag is equivalent of:<br />
 * <code>
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;sysproperty <br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key=&quot;gwt.args&quot; <br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value=&quot;-standardsMode -war ${war_dir} -logLevel WARN&quot; /&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;sysproperty key=&quot;java.awt.headless&quot; value=&quot;true&quot; /&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;sysproperty key=&quot;gwt.devjar&quot; value=&quot;${com.google.gwt:gwt-dev:jar}&quot; /&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&lt;sysproperty <br />
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key=&quot;java.util.logging.config.file&quot; <br /> 
 * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value=&quot;test/com/inetools/gwetons/client/devModeTest.logging.properties&quot; /&gt;<br />
 * </code> 
 * </blockquote>
 * </li>
 * </ul>
 * <b>Usage note</b>:
 * <ul>
 * <li>Only one each of <code>argext</code> tag and <code>jvmargext</code> tag is supported within single 
 * <code>javaext</code> tag. <br />
 * </li>
 * <li>Each argument is extracted as delimited by white space(s) except the case that argument value 
 * containing space(s) is surrounded by double quotation characters.
 * </li>
 * <li>As shown in the above examples, it also resolves <u>${property_name_or_reference_id} 
 * token</u> in each line in multiple-line arguments to actual value. Regarding that, please be advised 
 * the following points:
 * <ul>
 * <li>Such expression will be <u>resolved to actual string value even the expression is inside of 
 * surrounding quotation characters</u>.
 * </li>
 * <li>Effort of <u>resolving property name and reference name</u> to actual value will 
 * <u>be occurred recursively</u>.<br />
 * So, take the jvmargext example above, all arguments could be defined in single property 
 * (let's say jvmargprop for now) then the text content of the jvmargext tag could be simply 
 * stated as below and the ${agent_path} and ${some_path} property expressions would still be 
 * resolved to actual property values. 
 * <blockquote>
 * <code>
 * &lt;jvmargext&gt;<br />
 * &nbsp;&nbsp;&nbsp;&nbsp;${jvmargext}<br />
 * &lt;/jvmargext&gt;<br />
 * </code> 
 * </blockquote>
 * </li>
 * </ul>
 * </li>
 * </ul>  
 * </li>
 * </ul>
 * Of course, you can use the parameters of Ant's regular <code>java</code> tag with <code>javaext</code> 
 * tag too.
 * </li>
 * <li><h3><a id="configuration">Configuration</a></h3>
 * <ul>
 *  <li>In the <b>case of using maven-antrun-plugin</b><br />
 *  	<ol>
 *  	 <li>Define com.newmainsoftech:ant-util:jar as a dependency of maven-antrun-plugin:
 *  		<blockquote><code>
 *  		&lt;<b>plugin</b>&gt;<br />
 *  		&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
 *  		&nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>artifactId</b>&gt;<b>maven-antrun-plugin</b>&lt:/artifactId&gt;<br />
 *  		&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;dependencies&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>dependency</b>&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;<b>&lt;groupId&gt;com.newmainsoftech&lt;/groupId&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;artifactId&gt;ant-util&lt;/artifactId&gt;</b><br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;version&gt;#.#.#&lt;/version&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/dependency&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/dependencies&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 *  		&lt;/plugin&gt;<br />
 *  		</code></blockquote>
 * 		 </li>
 * 		 <li>Define <code>taskdef</code> tag under execution's configuration tag like:<br />
 * 			<blockquote><code>
 *  		&lt;<b>plugin</b>&gt;<br />
 *  		&nbsp;&nbsp;&nbsp;&nbsp;&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br />
 *  		&nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>artifactId</b>&gt;<b>maven-antrun-plugin</b>&lt:/artifactId&gt;<br />
 *  		&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;executions&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>execution</b>&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;id&gt;as_you_like&lt;/id&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;phase&gt;as you need&lt;/phase&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;goals&gt;&lt;goal&gt;run&lt;/goal&gt;&lt;/goals&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>configuration</b>&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;target name="what_ever_you_like"&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;<b>taskdef <br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resource="com/newmainsoftech/ant/antlib.xml" <br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;classpathref="maven.plugin.classpath"</b> /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;!-- Now you can use javaext tag --&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;javaext id="test_javaext_element_1" fork="true"<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;classname="com.newmainsoftech.ant.taskdefs.DummyAppForTestingJavaTaskExt"<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;classpathref="ant-util_test_path"<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 *  		&nbsp;&nbsp;&nbsp;&nbsp;output="${JavaTaskExtTestWorkFile1}"&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg value="-Djvmarg-value1=jvmargValue1" /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg value="-Djvmarg-value2=jvmargValue2" /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmarg line="-Djvmarg-line3=jvmargLine3 -Djvmarg-line4=jvmargLine4" /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;jvmargext&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;-Dmulti-line-jvmarg5=jvmargext5<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;-Dmulti-line-jvmarg6=jvmargext6<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/jvmargext&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;syspropext&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;sysprop.gwt.args=-standardsMode -war target/www-test -logLevel WARN -testBeginTimeout 5<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;sysprop.java.awt.headless=true<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;sysprop.gwt.devjar=D:\mvn_repo\com\google\gwt\gwt-dev\2.4.0\gwt-dev-2.4.0.jar<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;sysprop.java.util.logging.config.file=test/com/inetools/gwetons/client/devModeTest.logging.properties<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/syspropext&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;arg value="-Darg-value7=argValue7" /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;arg value="-Darg-value8=argValue8" /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;arg line="-Darg-line9=argLine9 -Darg-line10=argLine10" /&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;argext&gt<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;-Dmulti-line-arg11=argext11<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;-Dmulti-line-arg12=argext12<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/argext&gt<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/javaext&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/target&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/configuration&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/execution&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;
 * 			&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;&lt;/executions&gt;<br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;...<br />
 *  		&lt;/plugin&gt;<br />
 * 			</code></blockquote>
 * 		 </li>
 * 		</ol>
 *  </li>
 *  <li>If you cannot define com.newmainsoftech:ant-util:jar as a dependency in your project's
 *  	pom.xml, or the case of stand alone Ant environment
 *  	<ol>
 *  	 <li>Define <code>path</code> tag for this project's archive ant-util.jar file.<br />
 * 			<blockquote><code>
 * 			&lt;<b>path</b> <b>id</b>=&quot;<b>antutil_path</b>&quot; <br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;path=&quot;${path_to_ant-util_jar_file}&quot; /&gt;
 * 			</code></blockquote>
 *  	 </li>
 *  	 <li>Define <code>taskdef</code> tag for the ant-util's antlib.xml<br />
 * 			<blockquote><code>
 * 			&lt;<b>taskdef</b> <br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;<b>resource=&quot;com/newmainsoftech/ant/antlib.xml&quot;</b> <br />
 * 			&nbsp;&nbsp;&nbsp;&nbsp;<b>classpathref</b>=&quot;<b>antutil_path</b>&quot; /&gt;
 * 			</code></blockquote>
 *  	 </li>
 *  	</ol>
 *  </li>
 * </ul>
 * </li>
 * </ul>
 * 
 * @author <a href="mailto:artymt@gmail.com">Arata Y.</a>
 * @see CommandlineJavaExt
 */
public class JavaTaskExt extends Java {
	CommandlineJavaExt commandlineJavaExt = new CommandlineJavaExt();
	
	public JavaTaskExt() {
		super();
	}
	public JavaTaskExt( Task owner) {
		super( owner);
	}
	
	@Override
    public CommandlineJava getCommandLine() {
		return commandlineJavaExt;
	}
	
	public ArgumentExtContract createArgext() {
		return ((CommandlineJavaExt)getCommandLine()).createArgext();
	}
	
    public ArgumentExtContract createJvmargext() {
        return ((CommandlineJavaExt)getCommandLine()).createVmargext();
    }

	/**
	 * To add system property parameters to command line being used at execution of java app.
	 * 
	 * @param sysPropExt
	 */
	public void addConfiguredSysPropExt( SysPropExt sysPropExt) {
		List<Variable> propertyList = sysPropExt.getEnvVarList();
		CommandlineJava commandlineJava = getCommandLine();
		for( Variable evnVar : propertyList) {
			commandlineJava.addSysproperty( evnVar);
		} // for
	}
}
